﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsPdfToImg
{
    public static class Tools
    {
        /// <summary>
        /// 毫秒转换为 分和秒
        /// </summary>
        /// <param name="milliSeconds"></param>
        /// <returns></returns>
        public static string RevertToTime(long milliSeconds)//毫秒
        {
            double getsecond = milliSeconds * 1.0 / 1000;
            double getdoubleminuth = Math.Floor(getsecond / 60);
            string minuthTIme = string.Empty;
            string secondTime = string.Empty;
            string resultShow = string.Empty;
            if (getdoubleminuth >= 1)
            {
                minuthTIme = getdoubleminuth >= 10 ? $"{getdoubleminuth}" : $"0{getdoubleminuth}";
                double getmtemp = getdoubleminuth * 60;
                double getmtemp2 = getsecond - getmtemp;
                double timemiao = Math.Floor(getmtemp2);
                secondTime = $"{(timemiao >= 10 ? timemiao.ToString() : "0" + timemiao)}";
                resultShow = $"{minuthTIme}分{secondTime}秒";
            }
            else
            {
                secondTime = getsecond >= 10 ? getsecond.ToString() : ("0" + getsecond);
                resultShow = $"0分{secondTime}秒";
            }
            return resultShow;

            #region old
            //double getsecond = milliSeconds * 1.0 / 1000;//得到秒钟
            //double getdoubleminuth = getsecond * 1.0 / 60;//得到分钟
            //double scoreDes = Math.Round(getdoubleminuth, 0);
            //return scoreDes > 0 ? $"{scoreDes}分0秒" : $"0分{Math.Round(getsecond, 0)}秒";
            #endregion

        }
    }
}
